package com.aaa.controller.sds;

import com.aaa.controller.BaseController;
import com.aaa.entity.PageSortEntity;
import com.aaa.entity.Result;
import com.aaa.entity.sds.TestResultSds;
import com.aaa.entity.sds.ViewTestResultSds;
import com.aaa.service.sds.ViewTestResultSdsService;
import com.github.pagehelper.Page;
import org.omg.CORBA.PUBLIC_MEMBER;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (ViewTestResultSds)表控制层
 *
 * @author makejava
 * @since 2022-09-06 15:05:20
 */
@RestController
@RequestMapping("viewTestResultSds")
public class ViewTestResultSdsController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private ViewTestResultSdsService viewTestResultSdsService;


    /**
     * @param pageSortEntity
     * @param viewTestResultSds
     * @return
     * @create by: 张恒
     * @description: 查询
     * @create time: 2022/9/6 16:54
     */
    @RequestMapping("queryViewTestResultSds.do")
    public Result queryViewTestResultSds(PageSortEntity pageSortEntity, ViewTestResultSds viewTestResultSds) {
        Page page = viewTestResultSdsService.queryViewTestResultSds(pageSortEntity, viewTestResultSds);
        return success(page.getResult(), page.getTotal());
    }

    /**
     * @param
     * @return
     * @create by: 张恒
     * @description: 删除
     * @create time: 2022/9/6 17:06
     */
    @RequestMapping("deleteViewTestResultSds.do")
    public Result deleteViewTestResultSds(Integer[] id) {
        boolean b = viewTestResultSdsService.deleteViewTestResultSds(id);
        if (b) {
            return success();
        } else {
            return fail();
        }
    }


    /**
     * @param viewTestResultSds
     * @return
     * @create by: 张恒
     * @description: 根据id查询
     * @create time: 2022/9/6 19:15
     */
    @RequestMapping("queryViewTestResultSdsById.do")
    public Result queryViewTestResultSdsById(ViewTestResultSds viewTestResultSds) {
        ViewTestResultSds viewTestResultSds1 = viewTestResultSdsService.queryViewTestResultSdsById(viewTestResultSds);
        return success(viewTestResultSds1);
    }


    /**
     * @param
     * @return
     * @create by: 张恒
     * @description: 查询人数
     * @create time: 2022/9/6 20:34
     */
    @RequestMapping("queryViewTestResultSdsCount.do")
    public Result queryViewTestResultSdsCount() {
        Map<String, Integer> map = viewTestResultSdsService.queryViewTestResultSdsCount();
        return success(map);
    }



    /**
     * @create by: 张恒
     * @description: 查询问题学生
     * @create time: 2022/9/9 10:28
     * @param
     * @return
     */
    @RequestMapping("queryViewTestResultSdsBySum.do")
    public Result queryViewTestResultSdsBySum(Integer sum){
        List<ViewTestResultSds> viewTestResultSds = viewTestResultSdsService.queryViewTestResultSdsBySum(sum);
        return success(viewTestResultSds);
    }


    /**
     * @create by: 张恒
     * @description: 查看测试详情
     * @create time: 2022/9/13 9:03
     * @param pageSortEntity
     * @param id
     * @return
     */
    @RequestMapping("queryResultByQuestion.do")
    public Result queryResultByQuestion(PageSortEntity pageSortEntity, TestResultSds id){
        Page page = viewTestResultSdsService.queryResultByQuestion(pageSortEntity,id);
        return success(page.getResult(),page.getTotal());
    }
}

